﻿using System;
using Company.IO.Interfaces;
using Company.System.IO.IntegrationTests.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Company.System.IO.IntegrationTests
{
    public partial class DirectoryTest : TestBase<IDirectory>
    {
        private const string _SEnumerateFileSystemEntriesMethodName = "EnumerateFileSystemEntries";

        [TestMethod]
        public void EnumerateFileSystemEntries_PathNull_ArgumentNullException()
        {
            PathNull_ArgumentNullException(_SEnumerateFileSystemEntriesMethodName);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathNullSearchPatternNull_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(SStringNull, SStringNull);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes,
                                                   parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathNullSearchPatternNullSearchOptionAllDirectories_ArgumentNullException
            ()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(SStringNull, SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes,
                                                   parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathValidSearchPatternNull_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(_SEnumerateFileSystemEntriesMethodName, SStringNull);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes,
                                                   parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFileSystemEntries_PathValidSearchPatternNullSearchOptionAllDirectories_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(_SEnumerateFileSystemEntriesMethodName, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes,
                                                   parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathEmpty_ArgumentException()
        {
            PathEmpty_ArgumentException(_SEnumerateFileSystemEntriesMethodName);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathEmptySearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(string.Empty, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathEmptySearchPatternNullSearchOptionAllDirectories_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(string.Empty, SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisOnlyWhitespace_ArgumentException()
        {
            PathContaisOnlyWhitespace_ArgumentException(_SEnumerateFileSystemEntriesMethodName);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisOnlyWhitespaceSearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyWhitspace, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFileSystemEntries_PathContaisOnlyWhitespaceSearchPatternNullSearchOptionAllDirectories_ArgumentException
            ()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyWhitspace, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisOnlyColonChar_ArgumentException()
        {
            PathContaisOnlyColonChar_ArgumentException(_SEnumerateFileSystemEntriesMethodName);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisOnlyColonCharSearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyColonChar, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFileSystemEntries_PathContaisOnlyColonCharSearchPatternNullSearchOptionAllDirectories_ArgumentException
            ()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyColonChar, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisInvalidPathChar_ArgumentException()
        {
            PathContaisInvalidPathChar_ArgumentException(_SEnumerateFileSystemEntriesMethodName);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_PathContaisInvalidPathCharSearchPatternNull_ArgumentException()
        {
            //Arrange
            char[] invalidChars = global::System.IO.Path.GetInvalidPathChars();

            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(new string(invalidChars), SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFileSystemEntries_PathContaisInvalidPathCharSearchPatternNullSearchOptionAllDirectories_ArgumentException
            ()
        {
            //Arrange
            char[] invalidChars = global::System.IO.Path.GetInvalidPathChars();

            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(new string(invalidChars), SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFileSystemEntriesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_UnknownDirectory_DirectoryNotFoundException()
        {
            PathUnknown_DirectoryNotFoundException(_SEnumerateFileSystemEntriesMethodName, Resources.PathTooLong);
        }

        [TestMethod]
        public void EnumerateFileSystemEntries_UnknownDirectorySearchPatternEmpty_DirectoryNotFoundException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathTooLong, string.Empty);
            //Act
            ExpectException<global::System.IO.DirectoryNotFoundException>(_SEnumerateFileSystemEntriesMethodName,
                                                                          parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFileSystemEntries_UnknownDirectorySearchPatternEmptySearchOptionAllDirectories_DirectoryNotFoundException
            ()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathTooLong, string.Empty, SearchOption.AllDirectories);
            //Act
            ExpectException<global::System.IO.DirectoryNotFoundException>(_SEnumerateFileSystemEntriesMethodName,
                                                                          parameterTypes, parameterValues);
            //Assert
        }
    }
}